package com.example.demo.controller;

import com.example.demo.common.BasePageResponse;
import com.example.demo.common.ResultObject;
import com.example.demo.jooq.tables.pojos.Account;
import com.example.demo.jooq.tables.pojos.ShopOrder;
import com.example.demo.model.request.ApplyPageRequest;
import com.example.demo.model.request.OrderExportRequest;
import com.example.demo.model.request.OrderPageRequest;
import com.example.demo.model.request.OrderRequest;
import com.example.demo.model.response.AddressResponse;
import com.example.demo.model.response.OrderPageResponse;
import com.example.demo.service.order.IOrderService;
import com.example.demo.service.order.IVisaCardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("v1/order/")
public class OrderController {
    @Autowired
    private IOrderService iOrderService;
    @GetMapping(value = "list")
    public ResultObject<BasePageResponse<OrderPageResponse>> queryPageOrderList(OrderPageRequest applyPageRequest) {
        return iOrderService.queryPageOrderList(applyPageRequest);
    }

    /**
     * 账户保存
     * @param orderRequest 数据对象
     * @return
     */
    @PostMapping(value = "save")
    public ResultObject  saveOrder(@RequestBody OrderRequest orderRequest) {
        return iOrderService.saveOrder(orderRequest);
    }

    /**
     * 账户保存
     * @param orderId 订单ID
     * @return
     */
    @GetMapping(value = "detail")
    public ResultObject<OrderPageResponse>  queryOrderDetail(@RequestParam("orderId")String orderId) {
        return iOrderService.queryOrderDetail(orderId);
    }


    /**
     * 导出订单
     * @param orderExportRequest 请求
     * @return
     */
    @GetMapping(value = "export")
    public ResultObject exportOrderList(HttpServletResponse response,OrderExportRequest orderExportRequest) {
        return iOrderService.exportPageOrderList(response,orderExportRequest);
    }


    /**
     * 导出订单
     * @param orderExportRequest 请求
     * @return
     */
    @GetMapping(value = "third/refund/export")
    public ResultObject exportRefundOrderList(HttpServletResponse response,OrderExportRequest orderExportRequest) {
        return iOrderService.exportRefundOrderList(response,orderExportRequest);
    }
}
